<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改仪器信息')" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-information-edit" th:object="${tmdDeviceInformation}">
        <div class="form-group">
            <label class="col-sm-3 control-label">编号</label>
            <div class="col-sm-8">
                <input name="id" th:field="*{id}" type="text" readonly class="form-control">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">仪器名称</label>
            <div class="col-sm-8">
                <input type="text"  name="deviceName" th:field="*{deviceName}" class="form-control" placeholder="请输入名称" readonly>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">创建人:</label>
            <div class="col-sm-8">
                <input name="createPerson" th:field="*{createPerson}" type="text" readonly class="form-control">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">创建时间:</label>
            <div class="col-sm-8">
                <input name="createTime" th:value="${#dates.format(tmdDeviceInformation.createTime, 'yyyy-MM-dd HH:mm:ss')}" class="form-control" placeholder="yyyy-MM-dd hh:ss" type="text" readonly>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">部门:</label>
            <div class="col-sm-8">
                <select class="form-control" id="deptIdList" name="deptId" th:field="*{deptId}" readonly>
                    <option value="">请选择部门</option>
                    <option value="100">若依科技</option>
                    <option value="101">深圳总公司</option>
                    <option value="102">长沙分公司</option>
                    <option value="103">研发部门</option>
                    <option value="104">市场部门</option>
                    <option value="105">测试部门</option>
                    <option value="106">财务部门</option>
                    <option value="107">运维部门</option>
                    <option value="108">市场部门</option>
                    <option value="109">财务部门</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">型号规格:</label>
            <div class="col-sm-8">
                <input name="type" th:field="*{type}" class="form-control" type="text" readonly>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">主要技术指标:</label>
            <div class="col-sm-8">
                <input name="mainAim" th:field="*{mainAim}" class="form-control" type="text" readonly>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">鉴定有效期:</label>
            <div class="col-sm-8">
                <input name="valid" th:field="*{valid}" class="form-control" type="text" readonly>
                <span>(单位:天)</span>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">存放位置:</label>
            <div class="col-sm-8">
                <input name="savePosition" th:field="*{savePosition}" class="form-control" type="text" readonly>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">设备状态:</label>
            <div class="col-sm-8">
                <select class="form-control" name="deviceStatus" id="deviceStatus" th:field="*{deviceStatus}" readonly>
                    <option value="">请选择设备状态</option>
                    <option value="0">正常</option>
                    <option value="1">报废</option>
                    <option value="2">维修</option>
                    <option value="3">无效</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">附件:</label>
            <div class="col-sm-8">
                <input type="hidden" name="file" th:field="*{file}" readonly>
                <div class="file-loading">
                    <input class="form-control file-upload" id="file" name="file" type="file" readonly>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">备注:</label>
            <div class="col-sm-8">
                <textarea name="text" class="form-control" readonly>[[*{text}]]</textarea>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: bootstrap-fileinput-js"/>
<script th:inline="javascript">
    var prefix = ctx + "device/information";
    $("#form-information-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-information-edit').serialize());
        }
    }

    $(".file-upload").each(function (i) {
        var val = $("input[name='" + this.id + "']").val()
        $(this).fileinput({
            'uploadUrl': ctx + 'common/upload',
            initialPreviewAsData: true,
            initialPreview: [val],
            maxFileCount: 1,
            autoReplace: true
        }).on('fileuploaded', function (event, data, previewId, index) {
            $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
        }).on('fileremoved', function (event, id, index) {
            $("input[name='" + event.currentTarget.id + "']").val('')
        })
        $(this).fileinput('_initFileActions');
    });
</script>
</body>
</html>